package lt.egidijus.aatest.wizards.helpers.list;

import lt.egidijus.aatest.model.AAtestClass;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

public class TestWizardList {
	AAtestClass selectedItem = null;

	public AAtestClass getSelectedItem() {
		return selectedItem;
	}

	public TestWizardList(final Shell shell, Composite parent, int style,
			final java.util.List<AAtestClass> items, String text) {
		Label label = new Label(parent, SWT.NULL);
		label.setText(text);
		final List l = new List(parent, style | SWT.SINGLE);

		for (AAtestClass s : items) {
			l.add(s.getName());

		}

		l.addListener(SWT.Selection, new Listener() {

			@Override
			public void handleEvent(Event event) {
				selectedItem = items.get(l.getSelectionIndex());
			}
		});

	}
}
